import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:name_card_android/app_colors.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:name_card_android/state/appState.dart';
import 'package:provider/provider.dart';


import 'package:name_card_android/main_screen.dart';
import 'package:name_card_android/setting/setting_screen.dart';
import 'package:name_card_android/main_screen_state.dart';

void main() {
  SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
    statusBarColor: Colors.transparent, // 透明状态栏
    systemNavigationBarColor: Colors.transparent, // 透明导航栏
    statusBarIconBrightness: Brightness.dark, // 状态栏图标深色
    systemNavigationBarIconBrightness: Brightness.dark, // 导航栏图标深色
  ));

  // 可选：强制启用 Edge to Edge 模式（Android 10+）
  SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
  runApp(const MyApp());
}



class MyApp extends StatelessWidget {
  final ThemeType currentTheme = ThemeType.light;
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    final ThemeData themeData;
    switch (currentTheme) {
      case ThemeType.light:
        themeData = ThemeData(
          brightness: Brightness.light,
          primaryColor: AppTheme.lightTheme.primaryColor,
          secondaryHeaderColor: AppTheme.lightTheme.secondaryColor,
        );
      case ThemeType.blackAndWhite:
        themeData = ThemeData(
          brightness: Brightness.light,
          primaryColor: AppTheme.blackAndWhiteTheme.primaryColor,
          secondaryHeaderColor: AppTheme.blackAndWhiteTheme.secondaryColor,
        );
      case ThemeType.dark:
        themeData = ThemeData(
          brightness: Brightness.dark,
          primaryColor: AppTheme.darkTheme.primaryColor,
          secondaryHeaderColor: AppTheme.darkTheme.secondaryColor,
        );

    }

    return MultiProvider(
        providers: [
          ChangeNotifierProvider<AppState>(create: (_) => AppState()),
        ],
        child: MaterialApp(
      localizationsDelegates: AppLocalizations.localizationsDelegates,
      supportedLocales: AppLocalizations.supportedLocales,
      theme: themeData,
      initialRoute: '/',
      routes: {
        '/': (context) => const MainScreen(),
        '/setting':(context) => const SettingScreen(),
      },
    ));
  }
}


